--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local hy_misuteia_rorerai = General:new(extension, "hy_misuteia_rorerai", "jin_k", 4, 4, General.Female)
    local blind_eyes = fk.CreateSkill {
        name = "blind_eyes",
    }
    blind_eyes:addEffect(fk.TargetSpecifying, {
        anim_type = "negative",
        can_trigger = function(self, event, target, player, data)
            local room = player.room
            return player:hasSkill(blind_eyes.name) and player:inMyAttackRange(target) and table.contains(data:getAllTargets(), player) and
                #room.logic:getEventsOfScope(GameEvent.UseCard, 2, Util.TrueFunc, Player.HistoryTurn) == 1 and data.firstTarget
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            data.use.nullifiedTargets = player.room.players
        end,
    })
    local ostentatious_sound = fk.CreateSkill {
        name = "ostentatious_sound",
    }
    ostentatious_sound:addEffect("active", {
        anim_type = "drawcard",
        min_card_num = 1,
        card_filter = function(self, player, to_select, selected)
            if not table.contains(player.player_cards[Player.Hand], to_select) then
                return false
            end
            for _, id in ipairs(selected) do
                if Fk:getCardById(to_select).suit == Fk:getCardById(id).suit then
                    return false
                end
            end
            return true
        end,
        target_num = 1,
        target_filter = function(self, player, to_select, selected, selected_cards)
            return to_select ~= player and #selected == 0
        end,
        can_use = function(self, player)
            return player:usedSkillTimes(ostentatious_sound.name, Player.HistoryPhase) < 1
        end,
        prompt = function(self, selected_cards, selected_targets)
            return "ostentatious_sound_prompt"
        end,
        on_use = function(self, room, cardUseEvent)
            local player = cardUseEvent.from
            local target = cardUseEvent.tos[1]
            local cards = table.clone(cardUseEvent.cards)
            player:showCards(cards)
            for _, id in ipairs(cards) do
                if not table.contains(player:getCardIds("h"), id) then
                    table.removeOne(cards, id)
                end
            end
            if #cards > 0 then
                local marks = {}
                for _, id in ipairs(cards) do
                    local card = Fk:getCardById(id)
                    table.insertIfNeed(marks, card:getSuitString(true))
                end
                room:setPlayerMark(target, "@ostentatious_sound", marks)
                room:moveCards({
                    from = player,
                    to = target,
                    toArea = Card.PlayerHand,
                    ids = cards,
                    proposer = player,
                    moveReason = fk.ReasonGive,
                    skillName = ostentatious_sound.name,
                    moveVisible = false,
                })
            end
        end
    })
    ostentatious_sound:addEffect(fk.AfterCardsMove, {
        anim_type = "drawcard",
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(ostentatious_sound.name) and #table.filter(data, function(move)
                return #table.filter(move.moveInfo, function(info)
                    return table.contains({ Card.PlayerHand, Card.PlayerEquip }, info.fromArea)
                end) > 0 and move.from and move.from:getMark("@ostentatious_sound") ~= 0 and move.moveReason ~= fk.ReasonUse
            end) > 0
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            local room = player.room
            local card_ids = room:getNCards(4)
            local get, throw = {}, {}
            room:turnOverCardsFromDrawPile(player, card_ids, ostentatious_sound.name)
            table.forEach(room.players, function(p)
                room:fillAG(p, card_ids)
            end)
            local card_suits = {}
            for _, t in ipairs(room.players) do
                if t:getMark("@ostentatious_sound") ~= 0 then
                    table.insertTableIfNeed(card_suits, t:getMark("@ostentatious_sound"))
                end
            end
            for i = #card_ids, 1, -1 do
                local id = card_ids[i]
                if not table.contains(card_suits, Fk:getCardById(id):getSuitString(true)) then
                    room:takeAG(player, id)
                    table.insertIfNeed(throw, id)
                    table.removeOne(card_ids, id)
                end
            end
            if #card_ids == 0 then
                room:delay(1500)
            else
                if #card_ids == 1 then
                    room:delay(1500)
                end
                local card_id = room:askToAG(player, {
                    id_list = card_ids,
                    cancelable = false,
                    skill_name = ostentatious_sound.name
                })
                room:takeAG(player, card_id)
                table.insertIfNeed(get, card_id)
                table.removeOne(card_ids, card_id)
                table.insertTableIfNeed(throw, card_ids)
            end
            room:closeAG()
            if #get > 0 then
                local dummy = Fk:cloneCard("dilu")
                dummy:addSubcards(get)
                room:obtainCard(player, dummy, true, fk.ReasonPrey)
            end
            if #throw > 0 then
                room:cleanProcessingArea(throw, ostentatious_sound.name)
            end
        end,
    })
    ostentatious_sound:addEffect(fk.EventPhaseStart, {
        can_refresh = function(self, event, target, player, data)
            if not player:hasSkill(ostentatious_sound.name, true, true) or target ~= player then
                return false
            end
            return player.phase == Player.Play
        end,
        on_refresh = function(self, event, target, player, data)
            local room = player.room
            for _, t in ipairs(room.players) do
                room:setPlayerMark(t, "@ostentatious_sound", 0)
            end
        end
    })
    extension:loadSkillSkels { blind_eyes, ostentatious_sound }
    hy_misuteia_rorerai:addSkill("blind_eyes")
    hy_misuteia_rorerai:addSkill("ostentatious_sound")
    Fk:loadTranslationTable {
        ["hy_misuteia_rorerai"] = "米斯蒂娅",
        ["#hy_misuteia_rorerai"] = "夜盲之歌",
        ["illustrator:hy_misuteia_rorerai"] = "百夜イオリ",
        ["designer:hy_misuteia_rorerai"] = "黑曜人形",
        ["cv:hy_misuteia_rorerai"] = "",

        ["blind_eyes"] = "黯目",
        [":blind_eyes"] = "每回合使用的第一张牌指定目标时，若使用者在你攻击范围内且目标包含你，你令此牌无效。",

        ["ostentatious_sound"] = "喧音",
        [":ostentatious_sound"] = "出牌阶段限一次，你可以展示至少一张花色不同的手牌，然后将这些牌交给一名其他角色。若如此做，直到你的下个出牌阶段开始，当其不因使用而失去牌时，你亮出牌堆顶四张牌并获得其中一张与你以此法展示的牌的花色相同的牌。",
        ["@ostentatious_sound"] = "喧音",
        ["ostentatious_sound_prompt"] = "喧音：你可以将花色不同的手牌交给一名其他角色",
    }
end
